package com.jing.my;

import android.hardware.display.DisplayManager;
import android.speech.tts.TextToSpeech;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.DisplayCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.textview.MaterialTextView;
import com.jing.my.MainActivity.recyadapter.myholder;
import com.jing.my.R;
import android.os.Bundle;
import android.content.Context;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.shape.MaterialShapeUtils;
import com.google.android.material.button.MaterialButton;
import com.simple.spiderman.SpiderMan;
import java.util.ArrayList;

public class MainActivity extends AppCompatActivity implements TextToSpeech.OnInitListener {
	MaterialButton mb1;
	MaterialToolbar tb1;
	RecyclerView rv1;
	ArrayList<String> as = new ArrayList<String>();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		initviews();
		//	System.out.println("群主好帅！！！");
		//	setSupportActionBar(tb1);
		rv1.setHasFixedSize(true);
		LinearLayoutManager ll = new LinearLayoutManager(getApplicationContext());
		ll.setOrientation(LinearLayoutManager.VERTICAL);
		rv1.setLayoutManager(ll);
		for (int i = 0; i <= 100; i++)
			as.add("这是第" + i + "个item");
			
		rv1.setAdapter(new recyadapter());
	}

	void test() {
		new MaterialAlertDialogBuilder(this).setTitle("标题").setMessage("尼玛死逼").setPositiveButton("确定", null);

	}

	void initviews() {
		tb1 = findViewById(R.id.toolbar);
		rv1 = findViewById(R.id.rv);
	}

	@Override
	public void onInit(int status) {

	}

	public class recyadapter extends RecyclerView.Adapter<recyadapter.myholder> {

		public class myholder extends RecyclerView.ViewHolder {
			private MaterialTextView tt;

			public myholder(View v) {
				super(v);
				tt = (MaterialTextView) v.findViewById(R.id.tt);
			}

		}

		@Override
		public myholder onCreateViewHolder(ViewGroup arg0, int arg1) {
			View v1 = LayoutInflater.from(arg0.getContext()).inflate(R.layout.item, arg0, false);
			return new myholder(v1);
		}

		@Override
		public void onBindViewHolder(myholder arg0, int arg1) {
			arg0.tt.setText(as.get(arg1));
		}

		@Override
		public int getItemCount() {
			return as.size();
		}

	}
}
